package com.tiancheng.trade.payment.channel.enums;

import com.tiancheng.trade.commom.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 银联商务消息类型
 * 支付场景：
 * 1 - app中支付
 * 2 - 微信小程序支付
 * 3 - 微信公众号支付
 * 4 - h5支付
 * 5 - web扫码支付
 */
@Getter
@AllArgsConstructor
public enum UmsDhjtMsgTypeEnum implements BaseEnum<String> {
    wx_unifiedOrder("wx.unifiedOrder", "微信"),
    wx_miniPreOrder("wx.miniPreOrder", "商户微信小程序跳转银商统一封装小程序"),
    trade_create("trade.appPreOrder", "支付宝"),
    uac_miniOrder("uac.miniOrder", "云闪付");
    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<UmsDhjtMsgTypeEnum> typeEnum = Arrays.stream(UmsDhjtMsgTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (typeEnum.isPresent()) {
            return typeEnum.get().getDesc();
        }
        return "";
    }
}
